"""
函数：insert_img
实现：获取当前运行的路径，拼装截图名称，并生成截图
参数：
    driver: 浏览器对象
    name：截图名
返回值：无
"""
from selenium import webdriver
from time import sleep
from options import options
import os


# D:\python_pro\python_230901\day10_ddt\1_ddt basic\reports_assert\screenshots\baidu.png
def insert_img(dr, name):
    dir_name = os.path.dirname(__file__)
    # print(dir_name)
    up_dir_name = os.path.dirname(dir_name)
    # print(up_dir_name)
    img_name = rf'{up_dir_name}\reports\screenshots\{name}.png'
    # print(img_name)
    dr.get_screenshot_as_file(img_name)


if __name__ == '__main__':
    pass
    # name = 'baidu'
    # url = r'https://www.baidu.com/'
    # driver = webdriver.Chrome(options=options)
    # driver.get(url)
    #
    # insert_img(driver, name)
    #
    # driver.quit()
